import React, { Component } from "react";

export default class Header extends Component {
  addtask = (e) => {
    const { gid } = this
    const { addList } = this.props;
    console.log(e);
    if (e.keyCode == 13) {
      if(!e.target.value.trim()){
       return alert('不能为空')
      }
      addList({
        task:e.target.value,
        id:gid(),
        status:false
      });
      e.target.value = ''
    }
  };
  render() {
    return (
      <div className="header">
        <input
          type="text"
          placeholder="请输入你要的任务"
          onKeyUp={this.addtask}
        />
      </div>
    );
  }
}
